Skip to content

kernel daemon, ok, sys console#842

Closed
grypez wants to merge 5 commits intomainfrom
grypez/kernel-cli-command
Closed

kernel daemon, ok, sys console#842
grypez wants to merge 5 commits intomainfrom
grypez/kernel-cli-command

Conversation

@grypez
Copy link
Contributor

@grypez grypez commented Feb 18, 2026

demo

grypez and others added 5 commits February 17, 2026 18:29
…tils

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…patch

The system console vat manages a REPL loop over an IO channel,
dispatching CLI commands (help, status, launch, terminate, subclusters,
listRefs, revoke) and managing refs in persistent baggage. Refs use
a monotonic counter (d-1, d-2, ...) since crypto.randomUUID() is
unavailable under SES lockdown. Cross-vat errors are serialized via
JSON.stringify fallback for reliable error reporting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add startDaemon() which boots a kernel with a system console vat
listening on a UNIX domain socket IO channel. The kernel process IS
the daemon — no separate HTTP server. Includes socket channel fix to
block reads when no client is connected, flush-daemon utility, and
e2e tests for the full daemon stack protocol.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the 'ok' CLI that communicates with the kernel daemon over a UNIX
domain socket using newline-delimited JSON. Uses yargs for command
definitions with --help support on all commands. Supports three input
modes: file arg (ok file.ocap method), stdin redirect (ok launch <
config.json), and pipe (cat config.json | ok launch). Relative
bundleSpec paths in launch configs are resolved to file:// URLs
against CWD. Ref results are output as .ocap files when stdout is
not a TTY.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement a two-tier access model: unauthenticated daemon-tier commands
(help, status) and privileged ref-based dispatch via .ocap capability
files. Self-ref dispatch bypasses kernel round-trip for the console
root object. Fix kref leaks, improve socket channel reliability with
stale connection detection and client-side retry.
github-merge-queue bot pushed a commit that referenced this pull request Feb 20, 2026
Adds a long-running daemon process to the OCAP kernel, managed via new
`ocap daemon` CLI subcommands. The daemon spawns as a detached child
process, exposes the kernel's RPC service over a Unix domain socket
(`~/.ocap/daemon.sock`), and auto-starts on first `exec` invocation. The
kernel database is persisted at `~/.ocap/kernel.sqlite`.

Supersedes #842, and defers the introduction of its notion of a "console
vat" and repl / IO functionality to a later date.

### New CLI commands

- `ocap daemon start` — start the daemon (or confirm it is already
running)
- `ocap daemon stop` — gracefully shut down the daemon
- `ocap daemon purge --force` — stop the daemon and delete all persisted
state
- `ocap daemon exec [method] [params-json]` — send a JSON-RPC call to
the daemon (defaults to `getStatus`)

### Kernel changes

- `makeKernel()` now returns `{ kernel, kernelDatabase }` and accepts
optional `systemSubclusters`
- `ifDefined` utility moved from `kernel-agents` to `kernel-utils`
- `startRelay` moved from `cli` to `kernel-utils/libp2p`

### New modules

- `@ocap/nodejs/daemon` — daemon orchestration (`startDaemon`,
`deleteDaemonState`, `startRpcSocketServer`, socket line protocol)
- `@ocap/cli/commands/daemon*` — CLI-side daemon client, spawner, and
command handlers




<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **High Risk**
> Adds a new local RPC control plane (daemon + socket server) and
changes kernel construction/IO-channel semantics, which can impact
process lifecycle, persistence, and local security posture (e.g.,
arbitrary SQL via `executeDBQuery`).
> 
> **Overview**
> Adds a detached, long-running OCAP daemon that hosts kernel JSON-RPC
over a Unix domain socket and persists state under `~/.ocap`, with new
`ocap daemon start|stop|purge|exec` commands (including auto-spawn on
`exec`) and prototype safeguards/behavior documented.
> 
> Introduces `@ocap/nodejs/daemon` (RPC socket server, line protocol
helpers, daemon start/stop + state deletion) and updates `makeKernel` to
return `{ kernel, kernelDatabase }` (plus optional `systemSubclusters`)
to support the daemon lifecycle.
> 
> Refactors shared utilities by moving `startRelay` to
`@metamask/kernel-utils/libp2p` (and shifting libp2p deps accordingly)
and moving `ifDefined` into `@metamask/kernel-utils`; updates
tests/scripts and fixes `makeSocketIOChannel` reads to block until a
client connects (instead of returning `null`).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c0adc26. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: grypez <143971198+grypez@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@rekmarks
Copy link
Member

Superseded by #843. Exactly how we hook up the CLI to IO vats is tbd.

@rekmarks rekmarks closed this Feb 20, 2026
@rekmarks rekmarks deleted the grypez/kernel-cli-command branch February 20, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants